Skip to content

feat!: Introduce new summary section for data metrics#47

Open
Moritz Potthoff (MoritzPotthoffQC) wants to merge 26 commits into
mainfrom
data-inspection-section
Open

feat!: Introduce new summary section for data metrics#47
Moritz Potthoff (MoritzPotthoffQC) wants to merge 26 commits into
mainfrom
data-inspection-section

Conversation

@MoritzPotthoffQC

@MoritzPotthoffQC Moritz Potthoff (MoritzPotthoffQC) commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Motivation

See this discussion: We want to display data metrics in their own section in the summary.

Changes

  • Add differentiation for the metrics
  • Add new section Data Inspection that gets all the data metrics

@github-actions github-actions Bot added the enhancement New feature or request label Jul 17, 2026
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.73418% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.73%. Comparing base (01cef28) to head (8c7c45a).

Files with missing lines Patch % Lines
diffly/summary.py 97.91% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              main      #47      +/-   ##
===========================================
- Coverage   100.00%   99.73%   -0.27%     
===========================================
  Files           14       14              
  Lines         1052     1141      +89     
===========================================
+ Hits          1052     1138      +86     
- Misses           0        3       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Diffly’s summary reporting to distinguish change metrics (computed over deltas) from data inspection metrics (describing left/right datasets), and renders the latter in a new dedicated “Data Inspection” section while also separating them in the JSON schema.

Changes:

  • Add Metric.kind ("change" vs "data") and mark the Null% preset as a "data" metric.
  • Split per-column metric outputs into metrics vs data_metrics in the summary JSON, and render "data" metrics in a new “Data Inspection” section.
  • Update summary tests and regenerate pretty-output fixtures to reflect the new section/layout.

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
diffly/metrics/_common.py Adds Metric.kind to classify metrics by rendering section.
diffly/metrics/data.py Marks Null% preset as a "data" metric.
diffly/summary.py Routes metric labels into change vs data lists; adds “Data Inspection” rendering and JSON schema changes.
tests/summary/test_summary.py Adds coverage for metrics vs data_metrics JSON routing; updates expected JSON shape.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_True_slim_True_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_True_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_True_slim_False_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_True_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_False_slim_True_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_False_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_False_slim_False_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_False_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_True_slim_True_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_True_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_True_slim_False_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_True_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_False_slim_True_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_False_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_False_slim_False_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_False_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_True_slim_True_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_True_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_True_slim_False_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_True_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_False_slim_True_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_False_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_False_slim_False_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_False_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_True_slim_True_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_True_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_True_slim_False_sample_rows_True_sample_pk_True.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_True_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_False_slim_True_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_False_slim_True_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_False_slim_False_sample_rows_True_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.
tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_False_slim_False_sample_rows_False_sample_pk_False.txt Updates fixture output to move Null% into “Data Inspection”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread diffly/summary.py Outdated

@EgeKaraismailogluQC EgeKaraismailogluQC left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Moritz Potthoff (@MoritzPotthoffQC)! In general I am happy with the layout. I added a few comments. In addition to those, I think it would be nice to have at least one summary fixture where we render two or more data metrics rather than just one, just to see what that looks like (maybe I missed it?).

Comment thread diffly/summary.py Outdated
Comment thread diffly/metrics/_common.py Outdated
Comment thread diffly/metrics/_common.py Outdated
Comment thread diffly/metrics/data.py Outdated
@MoritzPotthoffQC
Moritz Potthoff (MoritzPotthoffQC) marked this pull request as draft July 22, 2026 17:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 51 out of 52 changed files in this pull request and generated 1 comment.

Comment thread diffly/metrics/__init__.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 84 out of 85 changed files in this pull request and generated 3 comments.

Comment thread diffly/comparison.py Outdated
Comment thread diffly/cli.py
Comment thread diffly/metrics/__init__.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@MoritzPotthoffQC

Copy link
Copy Markdown
Contributor Author

EgeKaraismailogluQC I made quite a few changes since your review. I'd appreciate another look. Let me know if you want to chat about this!

@EgeKaraismailogluQC EgeKaraismailogluQC left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this Moritz Potthoff (@MoritzPotthoffQC), looks very nice! Just a few cosmetic comments. Let's also add ! to the PR title to mark it as breaking.

Comment thread diffly/metrics/_common.py Outdated
Comment thread diffly/metrics/data.py Outdated
Comment thread diffly/comparison.py Outdated
Comment thread diffly/comparison.py Outdated
return v
# Infer the metric family from the callable's arity: a single-argument
# callable describes one side (data), two arguments describe a change.
if len(inspect.signature(v).parameters) >= 2:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not:

Suggested change
if len(inspect.signature(v).parameters) >= 2:
if isinstance(v, ChangeMetricFn):

Also, how about being a bit defensive here and do:

	elif isinstance(v, DataMetricFn):
		...
	else:
		raise

so that the signature issue is easier to understand for the user?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if isinstance(v, ChangeMetricFn): does not work as ChangeMetricFn is only as Callable type alias. But I now extended this to much more explicitly check the positional args in the methods that are provided.

Comment thread diffly/summary.py Outdated
Comment thread diffly/summary.py
Comment on lines 1033 to 1052
@@ -963,20 +1041,50 @@ def select_columns(selector: cs.Selector) -> set[str]:
for label, metric in metrics.items()
for column in sorted(metric_to_columns[label])
]
row = joined.select(agg_exprs).collect().row(0, named=True)
for label, columns in metric_to_columns.items():
for column in columns:

row = comp.joined(lazy=True).select(agg_exprs).collect().row(0, named=True)
out: dict[str, dict[str, Any]] = {
c: {} for c in set().union(*metric_to_columns.values())
}
for label in metrics:
for column in metric_to_columns[label]:
out[column][label] = row[f"{label}__{column}"]
return out

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I missing something or is this part just a "shallow" refactor?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right 👍 I refactored this a bit while I was working on this method (what is now _compute_data_metrics used to be entangled with this). I think it's easier to read this way, but we can also revert if you'd like

Comment thread diffly/metrics/data.py
Comment on lines +57 to +58
formatter=lambda value: f"{round(value * 100, 2)}%",
delta_formatter=lambda value: f"{round(value * 100, 2)}",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use these as the default formatter for DataMetric?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the percentage output is rather specific and would not fit for other data metrics I could imagine (e.g., mean). For floats, we already apply default formatting if no formatter is provided.

Comment thread diffly/metrics/_common.py
@MoritzPotthoffQC Moritz Potthoff (MoritzPotthoffQC) changed the title feat: Introduce new summary section for data metrics feat!: Introduce new summary section for data metrics Jul 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 84 out of 85 changed files in this pull request and generated 2 comments.

Comment thread diffly/comparison.py
Comment thread docs/api/metrics.rst Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants